<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>售后服务-{$webseting.web_title}</title>
    <script src="__PUBLIC__/wap/js/flexible.js"></script>
    <link href="__PUBLIC__/wap/css/icons.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/wap/css/base.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/wap/css/order.css" />

    <link href="__PUBLIC__/wap/css/service.css"  rel="stylesheet">
</head>
<style type="text/css">
  .img-item:before{background-image: none;}
</style>
<body id="u-body">
<div class="head">
    <a href="javascript:history.go(-1)" class="md-close back">
        <i class="iconfont">&#xe617</i>
    </a>
    <h2 >售后服务</h2>
</div>
        <div class="fm-wrap">
            <form id="form2" action=""  novalidate="novalidate" method="post" onSubmit="return false;">
                <div class="cartlist">
                    <ul>
                        <li  class="goods">
                            <div class="goodsimg imgnobg">
                                <div class="img bgcover " style=" background:url({:U('wap/index/get_thumbs',array('auto'=>64))}?img={$data.goods_image})">
                                </div>
                            </div>
                            <div class="info">
                                <div class="title">
                                    {$data.goods_name}
                                </div>
                                <div class="pay">
                                    <div class="pirce num green">
                                        ￥{$data.goods_price}
                                    </div>
                                    <div class="qty">
                                        <span class="num">{$data.goods_number}</span>件
                                    </div>
                                </div>
                            </div>
                            <div class="clearfix">
                            </div>
                        </li>
                    </ul>
                </div>
                <section class="miblewrap01 goods-apply-service">
                    <h3 class="mible-tit">联系人:{$refund['refund_name']}</h3>
                    <h3 class="mible-tit">联系电话:{$refund['refund_tel']}</h3>
                </section>
                <section class="miblewrap01 goods-apply-report">
                   <h3 class="mible-tit">状态：{$refund['code_name']}</h3>
                    <if condition="!empty($refund['refund_money']) && $refund['code'] eq 5">
                     <h3 class="mible-tit">退款金额：￥{$refund['refund_money']}</h3>
                 </if>
                    <h3 class="mible-tit">问题描述</h3>
                    <div class="fm-form">
                      {$refund['refund_remark']}
                    </div>
                </section>
                <if condition="!empty($refund['shop_remark'])">
                 <section class="miblewrap01 goods-apply-report">
                     <h3 class="mible-tit">商家回复</h3>
                    <div class="fm-form">
                      {$refund['shop_remark']}
                    </div>
                </section>
                 </if>
                
                <if condition="!empty($refund['refund_img'])">
                <section class="miblewrap01">
                    <h3 class="mible-tit">上传图片</h3>
                    <div  class="img-wrapper ">
                        <volist name="refund['refund_img']" id="vo">
                          <a href="{$vo}">
                          <div class="img-item fileinput " style="background-image:none;">
                            <span><img   src="{$vo}"></span>
                          </div>
                        </a>
                        </volist>
                    </div>
                    <div style="clear:both "></div>
                </section>
                </if>
                 <section class="miblewrap01 goods-return-type">
                    <h3 class="mible-tit">商品返回方式</h3>
                    <ul class="list-check-box">
                        <li class="list-item active" data-tab="2" data-value="4">
                            <div class="linein">快递FG峰购仓储</div>
                        </li>
                    </ul>
                      <div class="check-cnt-box" id="check-cnt-box2">
                            <p class="msg-text">商品返回地址将在服务单审核通过后刷新本页面查看</p>
                        </div>
                      <if condition="!empty($refund['send_address'])">
                        <div class="fm-form">
                         商品返回地址: {$refund['send_address']}
                        </div>
                      </if>
                       <if condition="in_array($refund['code'],array(2,3,4,5)) && !empty($refund['user_send_img'])">
                       <section class="miblewrap01 checked_img" style="display:none;">
                    <h3 class="mible-tit">上传发货单图片</h3>
                    <div  class="img-wrapper">
                        <a href="{$refund['user_send_img']}">
                          <div class="img-item fileinput " style="background-image:none;">
                            <span><img   src="{$refund['user_send_img']}"></span>
                          </div>
                        </a>
                    </div>
                  
                    <div style="clear:both "></div>
                </section>
                 </if>
                     <if condition="in_array($refund['code'],array(2,3,4,5)) && empty($refund['user_send_img'])">
                    <div class="check-cnt">
                      
                        <div class="check-cnt-box always-show">
                            <div class="fm-form" style="margin-top: 5px">
                               <h3 class="mible-tit">我的发货单</h3>
                                <div class="fm-item">
                                    <span class="label">快递名称：</span>
                                    <div class="item-col">
                                      {$refund['invoice_no_name']}
                                      </div>
                                </div>
                                <div class="fm-item">
                                    <span class="label">快递单号：</span>
                                    <div class="item-col">
                                       {$refund['invoice_no_user']}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                  </if>
                   <if condition="in_array($refund['code'],array(3,4,5)) && empty($refund['refund_type'])">
                    <div class="check-cnt">
                        
                        <div class="check-cnt-box always-show">
                            <div class="fm-form" style="margin-top: 5px">
                               <h3 class="mible-tit">商家发货单</h3>
                                <div class="fm-item">
                                    <span class="label">快递名称：</span>
                                    <div class="item-col">
                                      {$refund['invoice_no_shop_name']}
                                      </div>
                                </div>
                                <div class="fm-item">
                                    <span class="label">快递单号：</span>
                                    <div class="item-col">
                                       {$refund['invoice_no_shop']}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                  </if>
                     <if condition="$refund['code'] eq 1">
                    <div class="check-cnt">
                        <div class="check-cnt-box" id="check-cnt-box2">
                            
                        </div>
                        <div class="check-cnt-box always-show">
                            <div class="fm-form" style="margin-top: 5px">
                               <h3 class="mible-tit"><label><input type="radio" name="temp" value='1' />填写发货单</label></h3>
                                <h3 class="mible-tit"><label><input type="radio" name="temp" value='0' checked/>上传发货单图片</label></h3>
                              </div>
                          </div>         
                        <div class="check-cnt-box always-show checked_dan">
                            <div class="fm-form" style="margin-top: 5px">
                               <h3 class="mible-tit">填写发货单</h3>
                                <div class="fm-item">
                                    <span class="label">快递名称：</span>
                                    <div class="item-col">
                                        <input type="text" class="fm-text al" id="invoice_no_name" name="invoice_no_name" value="" placeholder="快递名称" ></div>
                                </div>
                                <div class="fm-item">
                                    <span class="label">快递单号：</span>
                                    <div class="item-col">
                                        <input type="text" class="fm-text al" id="invoice_no_user"  name="invoice_no_user"   placeholder="快递单号" value="">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                  </if>
                </section>
               <input type="hidden" name="send_img" id="send_img" value="0">
                <input type="hidden" class="fm-text al"  name="ref_id"   placeholder="" value="{$refund.ref_id}">
            </form>
             <if condition="$refund['code'] eq 1">
               <form id="form3" action=""  novalidate="novalidate" method="post" onSubmit="return false;">
                 <section class="miblewrap01 checked_img" style="display:none;">
                    <h3 class="mible-tit">上传发货单图片</h3>
                    <div  class="img-wrapper upload_file">
                        
                        <div class="upload-btn-box" style="display: inline-block">
                            <input id="up_img_url" type="file" name="questionPic"  class="upload-btn upload_input">
                        </div>
                      
                    </div>
                     <input type="hidden" name="user_send_img" id="user_send_img" value="">
                    <div style="clear:both "></div>
                    <div class="msg-text">上传发货单正面照1张不超过5M，支持JPG、BMP、PNG</div>
                </section>
                 <input type="hidden" name="send_img" id="send_img" value="1">
                <input type="hidden" class="fm-text al"  name="ref_id"   placeholder="" value="{$refund.ref_id}">
                  </form>
                  </if>
            
              <if condition="$refund['code'] eq 1">
            <div class="fm-btns"><a href="javascript:void(0);" class="btn-h3 btn-c3 phone_reg_btn">提交</a></div>
              <elseif condition="$refund['code'] eq 4"/>
            <div class="fm-btns"><a href="javascript:void(0);" class="btn-h3 btn-c3 phone_reg_btn1">确认收货</a></div>
              </if>
        </div>
 
 <include file="Public/wap_javascript" />    
        <!--微信分享-->    
 <include file="Public/share_weixin" />
<script src="__PUBLIC__/bootstrap/vendor/jquery-validation/jquery.validate.wap.js"></script>
<script src="__PUBLIC__/js/jquery.form.js"></script>
<script src="__PUBLIC__/bootstrap/vendor/ajaxfileupload/ajaxfileupload.js"></script>
  
        <script>
jQuery(document).ready(function() {

$("#form2").validate({
  rules: {
     invoice_no_name:'required',
    invoice_no_user: {
    required:true,
    number:true,
    rangelength: [10, 14],
   }
  },
  messages: {
    invoice_no_name:'<span class="icon-warning icon_warning"></span>&nbsp;请输入快递名称',
       invoice_no_user:{
        required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入快递单号',
        number:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的快递单号',
        rangelength:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的快递单号'
       }
  },
   focusInvalid:false,
  success: function(label) { 
            // set  as text for IE 
           // alert('ok'); 
            //label.html(" ").addClass("checked"); 
        }, 
        /*执行ajaxsubmit  */ 
        submitHandler: function(editform) { 

            var options = { 
                url :  "<?php echo U('Wap/goodsrefund/refund_status'); ?>", 
                type : "post" , 
                dataType:'json', 
                target : "#loader", 
                error: function(){layer.msg("服务器没有返回数据，可能服务器忙，请重试",{icon:5});}, 
                onwait : "正在处理信息，请稍候...",
                success: function(response){ 
                      // console.log(response);
                    //$("#loader").fadeIn(500).html(response.data).fadeOut(500); 
                    //$('#editform').hide(2000); 
                    if(response.status==1){
                        //alert("注册成功");
                        layer.msg('提交成功', {icon: 6,time:1500},function(){
                      //关闭后的操作
                      window.location.href="<?php echo U('Wap/goodsrefund/index',array('id'=>$data['rec_id'])); ?>"; 
                      }); 
                    }else{
                        layer.msg(response.error, {icon: 5}); 
                       // alert(response.error);
                    }
                }
            };
            setTimeout((function(opt){
                return function(){
                    $('#form2').ajaxSubmit(opt);
                }
            })(options), 300); 
            return false; 
        }

  });
$("#form3").validate({
  rules: {
     user_send_img:'required'
  },
  messages: {
    user_send_img:'<span class="icon-warning icon_warning"></span>&nbsp;请上传发货单图片'
  },
   focusInvalid:false,
  success: function(label) { 
            // set  as text for IE 
           // alert('ok'); 
            //label.html(" ").addClass("checked"); 
        }, 
        /*执行ajaxsubmit  */ 
        submitHandler: function(editform) { 

            var options = { 
                url :  "<?php echo U('Wap/goodsrefund/refund_status'); ?>", 
                type : "post" , 
                dataType:'json', 
                target : "#loader", 
                error: function(){layer.msg("服务器没有返回数据，可能服务器忙，请重试",{icon:5});}, 
                onwait : "正在处理信息，请稍候...",
                success: function(response){ 
                      // console.log(response);
                    //$("#loader").fadeIn(500).html(response.data).fadeOut(500); 
                    //$('#editform').hide(2000); 
                    if(response.status==1){
                        //alert("注册成功");
                        layer.msg('提交成功', {icon: 6,time:1500},function(){
                      //关闭后的操作
                      window.location.href="<?php echo U('Wap/goodsrefund/index',array('id'=>$data['rec_id'])); ?>"; 
                      }); 
                    }else{
                        layer.msg(response.error, {icon: 5}); 
                       // alert(response.error);
                    }
                }
            };
            setTimeout((function(opt){
                return function(){
                    $('#form3').ajaxSubmit(opt);
                }
            })(options), 300); 
            return false; 
        }

  });

$('.phone_reg_btn').click(function(){
  var chk_temp=$('input[name="temp"]:checked').val();
 if(chk_temp>0){
$('#form2').submit();
 }else{
  $('#form3').submit();
 }
    
});
$('input[name="temp"]').change(function(){
    var val=$(this).val();
    if(val>0){
      $('.checked_img').hide();
      $('.checked_dan').show();
    }else{
      $('.checked_img').show();
      $('.checked_dan').hide();
    }
});
 var temp=$('input[name="temp"]:checked').val();
    if(temp>0){
      $('.checked_img').hide();
      $('.checked_dan').show();
    }else{
      $('.checked_img').show();
      $('.checked_dan').hide();
    }
$('.phone_reg_btn1').click(function(){
      var options = { 
                url :  "<?php echo U('Wap/goodsrefund/refund_status1'); ?>", 
                type : "post" , 
                dataType:'json', 
                target : "#loader", 
                error: function(){layer.msg("服务器没有返回数据，可能服务器忙，请重试",{icon:5});}, 
                onwait : "正在处理信息，请稍候...",
                success: function(response){ 
                      // console.log(response);
                    //$("#loader").fadeIn(500).html(response.data).fadeOut(500); 
                    //$('#editform').hide(2000); 
                    if(response.status==1){
                        //alert("注册成功");
                        layer.msg('操作成功', {icon: 6,time:1500},function(){
                      //关闭后的操作
                      window.location.href="<?php echo U('Wap/goodsrefund/index',array('id'=>$data['rec_id'])); ?>"; 
                      }); 
                    }else{
                        layer.msg(response.error, {icon: 5}); 
                       // alert(response.error);
                    }
                }
            };
            setTimeout((function(opt){
                return function(){
                    $('#form2').ajaxSubmit(opt);
                }
            })(options), 300); 
});


});


    $(document).ready(function (e) {
         ///上传商家logo
        $('.upload_file').on('change','.upload_input', function () {
                 var goods_length=$(".user_send_img").length;
                if(goods_length>=1){
                     layer.msg('图片只能上传1张', {icon: 5}); 
                }else{
                    ajaxFileUploadMore('url',"{:U('admin/Imagecat/upload_ajax')}");
                }
        });
           $('.upload_file').on('click','.delete_img', function () {
            var __thiss=$(this);
             layer.confirm('确定删除该图片？', {
              btn: ['确定','取消'] //按钮
             },function(){
                 __thiss.remove();
                 $('input[name="user_send_img"]').val('');
               layer.msg('已删除', {icon: 6,time:1000}); 
              }, function(){
          
              });
        });

    });


    function show_head(head_file) {

        //插入数据库
        $("#head_photo_src").attr('src', head_file);
        var img = head_file.split('/');
      //  var file = '/' + img[3] + '/' + img[4] + '/' + img[5] + '/' + img[6];
        $("#photo_pic").val(head_file);
        //});

    }

//多文件上传带预览
    function ajaxFileUploadMore(imgid,  url) {

        $.ajaxFileUpload({
                    url: url,
                    secureuri: false,
                    fileElementId: "up_img_"+imgid,
                    dataType: 'json',
                    data: {name: 'logan', id: 'id'},
                    success: function (data, status)
                    {

                        if (typeof (data.error) != 'undefined')
                        {

                            if (data.error != '')
                            {
                                layer.msg(data.error, {icon: 5}); 
                            } else {

                                var resp = data.msg;
                                if (resp != '0000') {
                                    layer.msg(data.error, {icon: 5}); 
                                    return false;
                                } else {
                               var str_img=' <div class="img-item fileinput delete_img"><span><img  class="user_send_img"   src="'
                               +data.imgurl+'"></span></div>';
                                 $('.upload_file').prepend(str_img);
                                  $('input[name="user_send_img"]').val(data.imgurl);
                                }

                            }
                        }
                    },
                    error: function (data, status, e)
                    {
                        layer.msg('上传错误', {icon: 5}); 
                    }
                })

        return false;
    }
 
        </script>
</body>
</html>